package com.ae.shield.common.items.shieldFittings.makers;

import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;

import java.util.List;

public class EnergyShield extends ShieldMakerBase {
    public EnergyShield() {
        super(new Properties(), new ShieldMakerBase.ShieldProperty()
                .recovery(0.175f)
                .cd(56)
                .maxIntensity(20f)
                .close(1.4f)
                .remote(0.8f)
                .magic(0f)
                .other(0f)
                .upperLimit(30f)
                .floorLimit(0f)
                .maxPiles(2)
                .penalty(10f)
                .cost(7));
    }

    @Override
    public float consumeShield(ItemStack stack, float intensity, int plies) {
        if (getPlies(stack) < 1) {
            return intensity;
        }

        float residue = getIntensity(stack) - intensity;
        if (residue <= 0f) {
            setPlies(stack, getPlies(stack) - 1);
            setIntensity(stack, maxIntensity);
        } else {
            setIntensity(stack, residue);
        }

        if (getPlies(stack) == 0) {
            setIntensity(stack, 0f);
        }

        setPlies(stack, getPlies(stack) > plies ? getPlies(stack) - plies : 0);

        return 0f;
    }

    @Override
    public void addCtrlInformation(List<ITextComponent> components, ItemStack stack) {
        components.add(new TranslationTextComponent("tooltip.ae.shield.energy_shield.tip1").mergeStyle(TextFormatting.GRAY));
        components.add(new TranslationTextComponent("tooltip.ae.shield.energy_shield.tip2").mergeStyle(TextFormatting.GRAY));
        components.add(new TranslationTextComponent("tooltip.ae.shield.energy_shield.tip3").mergeStyle(TextFormatting.GRAY));
    }


}
